<template>
  <div>
    <div class="my">
      <h1>个人中心</h1>
      <div class="personal_center">
        <div class="icon_name clearfix">
          <img class="icon" src="../images/icon.jpg" alt="">
          <div class="right_detail">
            <span class="name">{{userInfo.name?userInfo.name:'海森堡'}}</span>
            <p class="autograph">{{userInfo.autograph?userInfo.autograph:'我于杀戮之中绽放,亦如黎明中的花朵'}}</p>
          </div>
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="jump">
        <van-cell title="个人信息" is-link url="http://www.baidu.com" />
        <van-cell title="换绑手机" is-link />
        <van-cell title="社交账号绑定" is-link />
        <van-cell title="登录密码" is-link />
        <van-cell title="支付设置" is-link />
        <van-cell title="关于我" class="aboutMe" @click="aboutME" />
      </div>
      <div class="edit">
        <van-button type="danger" @click="logout">退出账号</van-button>
      </div>
    </div>
    <Tabbar></Tabbar>
    <Loading v-if="isLoging"></Loading>
  </div>
</template>

<script>
import {mapGetters,mapState,mapMutations,mapActions} from "vuex";
import Tabbar from '@/components/Tabbar.vue'
import Header from '@/components/Header.vue'
import Loading from '@/components/Loading.vue'
import { Dialog } from 'vant';
export default {
    name: "My",
    data(){
        return{
          active:2,
          isLoging: false,
          isAplayer:null,//退出时隐藏播放器
          
        }
    },
    components: {
      Tabbar,
      Header,
      Loading

    },
    created(){
        this.active = sessionStorage.getItem('myactive');
    },
    computed: {
      ...mapState(["userInfo",])
    },
    methods:{
      //注销
      logout(){
        //控制显示播放器
        this.isAplayer = false;
        this.$store.commit('getAplayer',this.isAplayer)
        const  that = this;
        //删除cookie并跳到登录页
        that.isLoging = true;//加载loading
        that.delCookie('session');
        //注销时  清除sessionStorage里面的数据
        // sessionStorage.removeItem('userInfos');
        sessionStorage.clear();//清除所有缓存
        //演示
        setTimeout(()=>{
          that.$router.push('/login');
          that.isLoging = false;//去掉loading
          // window.location.reload();

        },1000)
        
    },

    // 关于我
    aboutME(){
      Dialog.alert({
        message:'wangyi404132@163.com'
      })
    }
  }
}
</script>

<style scoped lang="less">
  .van-cell:not(:last-child)::after{
    border-bottom: none;
  }

  .my{
    background-color: #eae8e8;
    h1{
      text-align: center;
      width: 100%;
      height: 50px;
      line-height: 50px;
      background-color: #fff;
    }
    .personal_center{
      height: 120px;
      background-color: #001938;
      position: relative;
      text-align: left;
      .icon_name{
        height: 50px;
        transform: translate(0,-50%);
        top: 50%;
        position: absolute;
        width: 100%;

        .name{
          display: inline-block;
          margin-top: 5px;
          color: #fff;
          font-weight: 600;
          font-size: 16px;
        }
        .autograph{
          color: #fff;
          font-size: 10px;
          margin-top: 5px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          width: 240px;
        }
        @media screen and (max-width: 320px) {
          .autograph{
            width: 200px;
          }
        }
        .van-icon-arrow{
          float: right;
          color: #fff;
          line-height: 50px;
          cursor: pointer;
          padding: 0 20px 0 10px;
        }
      }
      .icon{
        width: 50px;
        height: 50px;
        border-radius: 50%;
        margin-left: 15px;
        float: left;
      }
      .right_detail{
        float: left;
        margin-left: 10px;
      }
    }
    .jump{
      .van-cell{
        display: flex;
        box-sizing: border-box;
        width: 100%;
        padding: 6px 15px;
        overflow: hidden;
        color: #323233;
        font-size: 14px;
        line-height: 24px;
        background-color: #fff;
        text-align: left;
        border-bottom: 1px solid #ebedf0;
      }
      .aboutMe{
        margin-top: 30px;
      }
    }
    .edit{
      text-align: center;
      background-color: #fff;
      button{
        margin-top: 20px;
        width: 80%;
      }
      .van-button{
        height: 35px;
        line-height: 35px;
      }
    }
  }
</style>
